package com.yh.homestay.controller;

import com.yh.homestay.aop.SystemLog;
import com.yh.homestay.common.HomeStayResult;
import com.yh.homestay.pojo.CapitalRoom;
import com.yh.homestay.service.CapitalRoomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName CapitalRoomController
 * @Description 房间Controller
 * @Date 2020/1/2 9:07
 */
@RestController
@RequestMapping(value = "/room")
@Api(description = "房间管理")
public class CapitalRoomController {

    @Autowired
    private CapitalRoomService roomService;

    /**
     * @param
     * @Date: 2020/1/4 15:03
     * @Description: 展示房间信息列表
     * @return: com.yh.homestay.common.ResultMessage
     */
    @RequestMapping(value="/list",method = RequestMethod.GET)
    @SystemLog(methods="房间信息列表", module = "房间管理")
    @ApiOperation(value = "获取所有房间列表", notes = "获取所有房间信息或者模糊查询")
    public HomeStayResult showCapitalRoom(Integer page, Integer limit, String roomName) {
        return roomService.showCapitalRoom(page,limit,roomName);
    }

    /**
     * @param roomId
     * @Date: 2020/1/4 15:14
     * @Description: 删除单条数据
     * @return: com.yh.homestay.common.CapitalRoomResult
     */
    @RequestMapping(value = "/delete",method = RequestMethod.POST)
    @SystemLog(methods = "删除房间", module = "房间管理")
    @ApiOperation(value = "删除房间", notes = "删除单条数据")
    public HomeStayResult deleteCapitalRoom(Integer roomId) {
        return roomService.deleteCapitalRoom(roomId);
    }

    /**
     * @param ids
     * @Date: 2020/1/4 15:14
     * @Description: 批量删除房间信息
     * @return: com.yh.homestay.common.CapitalRoomResult
     */
    @RequestMapping(value = "/deleteBatch",method = RequestMethod.POST)
    @SystemLog(methods = "删除多个房间", module = "房间管理")
    @ApiOperation(value = "批量删除房间", notes = "根据ids批量删除房间")
    public HomeStayResult deleteCapitalRoom(String ids) {
        return roomService.deleteCapitalRoom(ids);
    }

    /**
     * @param room
     * @Date: 2020/1/4 15:21
     * @Description: 添加房间信息
     * @return: com.yh.homestay.common.CapitalRoomResult
     */
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    @SystemLog(methods = "添加房间", module = "房间管理")
    @ApiOperation(value = "添加房间", notes = "添加房间信息")
    public HomeStayResult addRoom(CapitalRoom room) {
        return roomService.insertCapitalRoom(room);
    }

    /**
     * @param id
     * @Date: 2020/1/4 17:17
     * @Description: 页面回显
     * @return: com.yh.homestay.pojo.CapitalRoom
     */
    @RequestMapping(value = "/one/{id}",method = RequestMethod.POST)
    @ApiOperation(value = "页面回显", notes = "根据房间id进行页面回显")
    public HomeStayResult showOne(@PathVariable("id") Integer id) {
        return roomService.showOneCapitalRoom(id);
    }

    /**
    * @Date: 2020/1/5 14:31
    * @Description: 编辑后更新数据
    * @param room
    * @return: com.yh.homestay.common.CapitalRoomResult
    */
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    @SystemLog(methods = "修改房间信息", module = "房间管理")
    @ApiOperation(value = "修改房间信息", notes = "修改房间信息")
    public HomeStayResult editRoom(CapitalRoom room) {
        return roomService.updateCapitalRoom(room);
    }

}
